package org.neuedu.controller;

import jakarta.annotation.Resource;
import org.neuedu.common.ResultJson;
import org.neuedu.entity.InspectionRequest;
import org.neuedu.service.InspectionRequestService;
import org.neuedu.vo.RegisterInspectionVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lzw
 * @since 2024-11-26
 */
@RestController
@RequestMapping("/inspectionRequest")
public class InspectionRequestController {
    @Resource
    InspectionRequestService inspectionRequestService;
    @PostMapping("/add")
    ResultJson<Boolean> add(InspectionRequest inspectionRequest, Long openId) {
        System.out.println(inspectionRequest);
        return ResultJson.success(inspectionRequestService.add(inspectionRequest, openId), "开立检查单成功");
    }
    @GetMapping("/list")
    ResultJson<RegisterInspectionVo> list(String caseNumber, String checkState) {
        return ResultJson.success(inspectionRequestService.list(caseNumber, checkState));
    }

    @GetMapping("/jiaofeiList")
    ResultJson<List<InspectionRequest>> jiaofeiList(String caseNumber, String realName, String checkState) {
        return ResultJson.success(inspectionRequestService.jiaofeiList(caseNumber, realName, checkState));
    }
    @PostMapping("/updateState")
    ResultJson<Boolean> updateState(Integer[] ids) {
        return ResultJson.success(inspectionRequestService.updateState(ids));
    }
    @PostMapping("/addResult")
    ResultJson<Boolean> addResult(Integer id, String text, Long openId) {
        return ResultJson.success(inspectionRequestService.addResult(id, text, openId), "结果录入完成");
    }
    @GetMapping("/getResult")
    ResultJson<List<InspectionRequest>> getResult(Integer registerId, String checkState) {
        return ResultJson.success(inspectionRequestService.getResult(registerId, checkState));
    }
}
